import java.util.Arrays;
import java.util.Objects;

/**
 * @author LKQ
 * @date 2022/2/21 22:25
 * @description 转换为字符串，然后按字典序降序排。
 */
public class Solution2 {
    public static void main(String[] args) {
        Solution2 solution2 = new Solution2();
        int[] nums = {0, 0};
        solution2.largestNumber(nums);
    }
    public String largestNumber(int[] nums) {
        int n = nums.length;
        String[] value = new String[n];
        for (int i = 0; i < n; i++) {
            value[i] = String.valueOf(nums[i]);
        }
        Arrays.sort(value, (a, b) -> {
            // 将两个字符串连接，然后降序比较
            String s1 = a + b;
            String s2 = b + a;
            return s2.compareTo(s1);
        });
        if (Objects.equals(value[0], "0")) {
            return "0";
        }
        StringBuffer sb = new StringBuffer();
        for (String val : value) {
            sb.append(val);
        }
        return sb.toString();
    }
}
